package books4africa

class Books {
	String title
	String author
	String description
	String isbn
	String category
	
	int edition
	int minGradeLevel
	int maxGradeLevel	
	
	static hasMany = [ranks:Ranking, inventory:Inventory, donation:Donation]
	
    static constraints = {
		title(blank:false)
		author(blank:false)
		isbn(matches:"([0-9]{10}|[0-9]{13})", nullable:true)
		description(nullable:true)
		
		category(inList:['General Leisure Reading', 'Reading Skills', 
			'Math Skills', 'Health', 'Sciences'], nullable:true)
		
		minGradeLevel(matches:"[0-6]{1}", blank:false)
		maxGradeLevel(matches:"[0-6]{1}", blank:false)
		
    }
	
	String toString(){
		"${title} - ${author}"
	}
}
